﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace MainWebService
{
    public class ServiceDetails
    {
        private int p;

        public ServiceDetails()
        {

        }
        public ServiceProperties AdvanceProperties { get; set; }
        public ServiceDetails(int serviceId, int clientId, string hashCode)
        {
            List<ServiceDetails> _srv = GetServiceDetails(clientId, hashCode);
            if (_srv != null && _srv.Count > 0)
            {
                ServiceDetails _srvDetail = _srv.First(m => m.ServiceId == serviceId);
                if (_srvDetail != null)
                {
                    this.ServiceId = _srvDetail.ServiceId;
                    this.ServiceName = _srvDetail.ServiceName;
                    this.ServiceType = _srvDetail.ServiceType;
                    this.ServiceSubType = _srvDetail.ServiceSubType;
                    this.ServiceDetail = _srvDetail.ServiceDetail;
                    this.ServiceDescription = _srvDetail.ServiceDescription;
                    this.ServiceURL = _srvDetail.ServiceURL;
                    this.ImageIconURL = "http://ssica.org/" + _srvDetail.ImageIconURL;
                    this.ServiceQuestions = _srvDetail.ServiceQuestions;
                    this.UserNamesList = _srvDetail.UserNamesList;
                    this.DBId = _srvDetail.DBId;
                    try
                    {
                        this.AdvanceProperties = new ServiceOperations().GetServiceProperties(_srvDetail.ServiceId, clientId);
                    }
                    catch (Exception ex) { }
                }
            }
        }
        public int ServiceId { get; set; }
        public string ServiceName { get; set; }
        public string ServiceType { get; set; }
        public string ServiceSubType { get; set; }
        public string ServiceDetail { get; set; }
        public string ServiceDescription { get; set; }
        public DataSet GetUserList { get; set; }
        public string UserNamesList { get; set; }
        public string DBName { get; set; }
        public int DBId { get; set; }
        public string CreateDate { get; set; }
        public string ImageIconURL { get; set; }
        public string ServiceURL { get; set; }
        public List<Questions> ServiceQuestions { get; set; }

        internal DataSet GetServiceList(int clientId, string hashCode)
        {
            ServiceOperations _srvOps = new ServiceOperations();
            return _srvOps.GetServices(clientId, hashCode);
        }

        internal List<ServiceType> GetServiceType()
        {
            ServiceOperations _srvOps = new ServiceOperations();
            return _srvOps.GetServiceType();
        }

        internal string CreateService(string serviceName, string serviceType, string serviceSubType, int userId, string hashCode, string serviceDes, string serviceDetail, string iconURL, string serviceURL, ref int serviceId)
        {
            ServiceOperations _srvOps = new ServiceOperations();
            return _srvOps.CreateService(serviceName, serviceType, serviceSubType, userId, hashCode, serviceDes, serviceDetail, iconURL, serviceURL, ref serviceId);
        }

        internal List<ServiceDetails> GetServiceDetails(int clientId, string hashCode)
        {
            ServiceOperations _srvOps = new ServiceOperations();
            return _srvOps.GetServiceDetails(clientId, hashCode);
        }

        internal string CreateService(ValidateScan scan)
        {
            ServiceOperations _srvOps = new ServiceOperations();
            return _srvOps.CreateService(scan);
        }

        internal void UpdateService(int UserId, string HashCode, int ServiceId, string serviceName, string serviceDetail)
        {
            new ServiceOperations().UpdateService(UserId, HashCode, ServiceId, serviceName, serviceDetail);
        }
    }
    public class ServiceType
    {
        public int ServiceTypeId { get; set; }
        public string ServiceDescription { get; set; }
        public string ServiceName { get; set; }
        public string ServiceUrl { get; set; }
    }

    public class ServiceProperties
    {
        public bool DeleteSavedScans { get; set; }
        public bool EditSavedAnswers { get; set; }
        public bool ViewOtherScans { get; set; }
        public bool StrictlyOnline { get; set; }

        public string EmailMeOnUploadEmailId { get; set; }

        public string AllowedBarCodes { get; set; }
    }
}